<?php echo $header; ?>

<div id="content">
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>   
    <?php echo $infocustomer?>  
    <div class="box">
        
        <div class="heading">
           <h1><img src="view/image/report.png" alt="" /> <?php echo $heading_title1; ?></h1>
          
            <div class="buttons">
                 
               
                  <a align="center" onclick="window.open('<?php echo $export_excel; ?>', '_blank')" class="button"><?php echo $button_export_excel; ?></a>                
        </div>
        </div>
          
          
        <div class="content">
            
            <form action="" method="post" enctype="multipart/form-data" id="form">
               
          
                
        <table class="list">
         <thead>
          <tr>      
            <td class="left"><?php echo $customerbills; ?></td>
            <td class="left"><?php echo $customerdate_enter; ?></td>
            <td class="left"><?php echo $customertamount; ?></td>
            <td class="left"><?php echo $point; ?></td>
            <td class="left"><?php echo $billsdetailed; ?></td>           
          </tr>
        </thead>
        <tbody>
            <tr class="filter">
                <td style="width: 300px;"><input type="text" name="bill" value="<?php echo $bill; ?>"></td>
                <td style="width: 300px;"><input type="text" name="date_bill" id="date_enter" value="<?php echo $date_bill; ?>"></td>
                <td></td>
                <td></td>
                <td  style="text-align: center"><a class="button" onclick="Filter();">Filter</a></td>
            </tr>
             <?php if($bills[0]!=null) { ?>
           
            <?php foreach ($bills as $bill) { ?>
            
             <tr>
            <td><?php echo $bill['bill']?></td>   
            
           <td><?php echo $bill['bill_date']?></td>   
            <td><?php echo $bill['customertamount'] ?></td>  
            
             <td><?php echo $bill['point'] ?></td> 
            <td class="center">
                 <a href="<?php echo $bill['href']; ?>">Xem</a> 
                </td>           
            
            
            <?php } ?>
             <?php } ?>
             </tr>
             
        </tbody>
        </table>
         <div class="pagination"><?php echo $pagination; ?></div>
        </form>
        </div>          
    </div> 
<script type="text/javascript"><!--
    function Filter()    {
    url = 'index.php?route=Mart_Crm/Crm_customer/bills&token=<?php echo $token; ?>&id=<?php echo $id; ?>';
    var bill = $('input[name=\'bill\']').attr('value');
    if(bill) {
    url += '&bill=' + encodeURIComponent(bill);
          }
    var date_bill = $('input[name=\'date_bill\']').attr('value');
    if(date_bill){
    url += '&date_bill=' + encodeURIComponent(date_bill);
}
    location = url;
};
   //--> </script>
<script type="text/javascript"><!--
    $(document).ready(function() {
     $('#date_enter').datepicker({dateFormat:'dd-mm-yy'}) 
});
//--></script>
<script type="text/javascript">
$('#form input').keydown(function(e){
  if(e.keyCode == 13){
  Filter();
}
});
</script>
<script type="text/javascript"><!--
$('input[name=\'bill\']').autocomplete({
	delay: 0,
	source: function(request, response) {
		$.ajax({
			url: 'index.php?route=Mart_Crm/Crm_customer/autocomplete_bill&token=<?php echo $token; ?>&id=<?php echo $id; ?>&bill=' +  encodeURIComponent(request.term),
			dataType: 'json',
			success: function(json) {		
				response($.map(json, function(item) {
					return {
						label: item.bill
						//value: item.last_name
					}
				}));
			}
		});
	}, 
	select: function(event, ui) {
		$('input[name=\'bill\']').val(ui.item.label);
						
		return false;
	},
	focus: function(event, ui) {
      	return false;
   	}
});
//--></script> 
    <?php echo $footer; ?>